/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package radio.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Huu Vinh
 */
@Entity
@Table(name = "AdvertiseType", catalog = "Radio_Cabs", schema = "dbo", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"AdvertiseName"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AdvertiseType.findAll", query = "SELECT a FROM AdvertiseType a"),
    @NamedQuery(name = "AdvertiseType.findByAdvertiseTypeId", query = "SELECT a FROM AdvertiseType a WHERE a.advertiseTypeId = :advertiseTypeId"),
    @NamedQuery(name = "AdvertiseType.findByAdvertiseName", query = "SELECT a FROM AdvertiseType a WHERE a.advertiseName = :advertiseName")})
public class AdvertiseType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "AdvertiseTypeId", nullable = false)
    private Integer advertiseTypeId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "AdvertiseName", nullable = false, length = 50)
    private String advertiseName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "advertiseTypeId")
    private List<Advertise> advertiseList;

    public AdvertiseType() {
    }

    public AdvertiseType(Integer advertiseTypeId) {
        this.advertiseTypeId = advertiseTypeId;
    }

    public AdvertiseType(Integer advertiseTypeId, String advertiseName) {
        this.advertiseTypeId = advertiseTypeId;
        this.advertiseName = advertiseName;
    }

    public Integer getAdvertiseTypeId() {
        return advertiseTypeId;
    }

    public void setAdvertiseTypeId(Integer advertiseTypeId) {
        this.advertiseTypeId = advertiseTypeId;
    }

    public String getAdvertiseName() {
        return advertiseName;
    }

    public void setAdvertiseName(String advertiseName) {
        this.advertiseName = advertiseName;
    }

    @XmlTransient
    public List<Advertise> getAdvertiseList() {
        return advertiseList;
    }

    public void setAdvertiseList(List<Advertise> advertiseList) {
        this.advertiseList = advertiseList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (advertiseTypeId != null ? advertiseTypeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AdvertiseType)) {
            return false;
        }
        AdvertiseType other = (AdvertiseType) object;
        if ((this.advertiseTypeId == null && other.advertiseTypeId != null) || (this.advertiseTypeId != null && !this.advertiseTypeId.equals(other.advertiseTypeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "radio.entities.AdvertiseType[ advertiseTypeId=" + advertiseTypeId + " ]";
    }
    
}
